import Vue from 'vue'
import App from './App.vue'
import router from './router'
import axios from "axios"
import store from "./store/index"
import moment from 'moment'

import echarts from 'echarts'
Vue.prototype.$echarts = echarts


import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';

import VueJsonp from 'vue-jsonp'
Vue.use(VueJsonp)



Vue.filter('dataFormat', function (dataStr, pattern = 'YYYY-MM-DD HH:mm:ss') {
  return moment(dataStr).format(pattern);
})

Vue.use(ElementUI);


import VueQuillEditor from 'vue-quill-editor'
// require styles 导入富文本编辑器对应的样式
import 'quill/dist/quill.core.css'
import 'quill/dist/quill.snow.css'
import 'quill/dist/quill.bubble.css'
// 将富文本编辑器，注册为全局可用的组件
Vue.use(VueQuillEditor)


axios.defaults.baseURL = "http://127.0.0.1:8888/"

//拦截器，给请求头加一个token
axios.interceptors.request.use(config => {


  if (window.sessionStorage.getItem("token")) {
    config.headers.Authorization = "Bearer " + window.sessionStorage.getItem("token")
    return config
  } else {
    return config
  }
})



Vue.prototype.$http = axios

Vue.config.productionTip = false

new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')